﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="OneMG.Phoenix.AdminSite.Views.New.Edit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    编辑新闻
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadScripts" runat="server">
    <script charset="utf-8" src="/scripts/kindeditor/kindeditor-min.js" type="text/javascript"></script>
    <script charset="utf-8" src="/scripts/kindeditor/lang/zh_CN.js" type="text/javascript"></script>
    
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="pd10">
        <form id="form1" method="post">
        <input type="hidden" id="hdaction" name="hdaction" value="<%=(objNews!=null)?"3":"1" %>" />
        <input type="hidden" id="hdnewsid" name="hdnewsid" value="<%=(objNews!=null)?objNews.NewsID : 0 %>" />

        <table class="tb-list mt10">
            <tr>
                <td class="aR">
                    分类：
                </td>
                <td class="aL">
                    <select id="sltCategory" name="sltCategory">
                        <%foreach (OneMG.Phoenix.Service.Model.CategoryModel c in CategoryList)%>
                        <%{%>
                        <% if (objNews != null && c.CategoryID == objNews.CateID) %>
                        <%{%>
                        <option value="<%=c.CategoryID %>" selected="selected">
                            <%=c.CategoryName%></option>
                        <%}%>
                        <%else %>
                        <%{ %>
                        <option value="<%=c.CategoryID %>"><%=c.CategoryName%></option>
                        <%} %>
                        <%}%>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="aR">
                    标题：
                </td>
                <td class="aL">
                    <input type="text" name="txtTitle" id="txtTitle" value="<%=(objNews!=null)?objNews.Title:"" %>" maxlength="200" style="width: 350px" class="inputStyle" />
                </td>
            </tr>
            <tr>
                <td class="aR">
                    操作：
                </td>
                <td class="aL">
                    置顶
                    <input id="chkIsTop" type="checkbox" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;显示<input id="IsShow" type="checkbox" />
                </td>
            </tr>
            <tr>
                <td class="aR">
                    概要：
                </td>
                <td class="aL">
                    <textarea name="txtSummary" id="txtSummary" style="width: 100%; height: 150px;"><%=(objNews != null) ? objNews.Summary : ""%></textarea>
                </td>
            </tr>
            <tr>
                <td class="aR">
                    说明：
                </td>
                <td class="aL">
                    <textarea name="content" style="width: 100%; height: 350px;"><%=(objNews != null) ? objNews.Description : ""%></textarea>
                </td>
            </tr>
        </table>
        <div class="aC">
            <input name="save" value="保存" type="button" class="a-btn1" />
            <input name="clear" value="清空" id="clear" type="button" class="a-btn1" /></div>
        </form>
    </div>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Scripts" runat="server">
<script type="text/javascript">
    var editor;
    KindEditor.ready(function(K) {
        editor = K.create('textarea[name="content"]', {
            allowFileManager: true
        });
        K('input[name=save]').click(function(e) {

            if (editor.text() == "") {
                alert('请输入新闻内容!');
                return false;
            }

            if ($("#txtTitle").val() == "") {
                alert('请输入新闻标题!');
                return false;
            }

            if ($("#txtSummary").val() == "") {
                alert('请输入新闻摘要!');
                return false;
            }

            var txt = editor.html();
            $.ajax({
                url: "/Views/New/Save.ashx",
                data: { "action": $("#hdaction").val(), "newsid": $("#hdnewsid").val(), "sltCategory": $("#sltCategory").val(), "title": encodeURI($("#txtTitle").val()), "summary": encodeURI($("#txtSummary").val()), "description": encodeURI(txt) },
                type: "post",
                success: function(data) {
                    if (data.status == "error" || data.status == "warning") {
                        alert(data.msg);
                        return;
                    }
                    alert(data.msg);
                }
            })
        });

        K('input[name=clear]').click(function(e) {

        editor.html('');
        });
    });
    </script>
</asp:Content>
